<template>
  <!-- 明细清单新增-->
  <el-dialog
    title="明细清单新增104"
    center
    :visible.sync="open"
    width="1024px"
    :close-on-click-modal="true"
    @close="closeFn"
    append-to-body
  >
    <el-form ref="detailsForm" :model="formData" label-width="130px" :rules="rules">
      <el-row type="flex">
        <el-col :span="12">
          <el-form-item label="征收机关大类代码：" prop="deptCode">
            <el-select v-model="formData.deptCode" placeholder="" style="width: 100%">
              <el-option
                v-for="dict in dictMap.DEPT_CODE"
                :key="dict.value"
                :label="`${dict.value}-${dict.text}`"
                :value="dict.value"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="预算科目代码：" prop="subjectCode">
            <acct-no-input v-model="formData.subjectCode" placeholder=""/>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="发生额币种：" prop="curcd">
            <el-input v-model="formData.curcd" placeholder="" disabled/>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="发生额：" prop="incurredAmount">
            <ht-amount-input v-model="formData.incurredAmount" placeholder=""/>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="saveFn" :loading="isLoading">保存</el-button>
    </div>
  </el-dialog>
</template>
<script>
import HtAmountInput from "@/views/components/HtAmountInput/index.vue";
import acctNoInput from "@/views/components/AcctNoInput/index.vue";

export default {
  name: "TableDialog",
  components: {HtAmountInput, acctNoInput},
  props: {
    dictMap: {
      type: Object,
      default: () => {
        return {};
      },
    },
    formData: {
      type: Object,
      default: () => {
        return {};
      },
    },
  },
  data() {
    return {
      rules: {
        deptCode: [
          {
            required: true,
            message: "不能为空",
            trigger: "change",
          },
        ],
        subjectCode: [
          {
            required: true,
            message: "不能为空",
            trigger: "blur",
          },
          {
            max: 20,
            message: "预算科目代码最长20位",
            trigger: "blur",
          }
        ],
        incurredAmount: [
          {
            required: true,
            message: "不能为空",
            trigger: "blur",
          },
        ],
      },
      // 是否显示弹出层
      open: false,
      isLoading: false,
    };
  },
  mounted() {
  },
  methods: {
    // 审核方法
    saveFn() {
      this.$refs["detailsForm"].validate((valid) => {
        if (valid) {
          this.isLoading = true;
          this.$emit("saveComplete104", this.formData);
          this.msgSuccess("保存成功!");
          this.closeFn();
        }
      });
    },
    // 表单重置
    reset() {
      this.resetForm("detailsForm");
    },
    closeFn() {
      this.open = false;
      this.isLoading = false;
    },
    show() {
      this.open = true;

      this.reset();
    },
  },
};
</script>
